<html>
<head><meta charset="utf-8"><title>core::io · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html">core::io</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189003625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189003625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189003625">(Feb 25 2020 at 09:34)</a>:</h4>
<p>Hi,<br>
How do people feel about moving most of <code>std::io</code> to <code>core::io</code> in the next edition? this will require a new <code>Error</code> type for the return value of the traits.<br>
I think this is one of the main hurdles for no-std now that we have <code>alloc</code>. I'm willing to put in the time to implement this but I don't want to waste that time if no one else thinks it's a good idea or if people think that even for editions it's a really big breaking change</p>



<a name="189005631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189005631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189005631">(Feb 25 2020 at 10:05)</a>:</h4>
<p>Have you considered moving it to <code>alloc</code>, which would allow us to keep the same <code>Error</code> type? Or do you really need it in <code>core</code>?</p>



<a name="189005879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189005879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189005879">(Feb 25 2020 at 10:08)</a>:</h4>
<p>I feel that using different <code>Error</code> types for <code>core::io</code> and <code>std::io</code> would be poorly received.</p>



<a name="189005994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189005994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189005994">(Feb 25 2020 at 10:10)</a>:</h4>
<p>There's also the issue that a lot of I/O types are very OS-specific, e.g. <code>IoSlice</code> is a wrapper around an OS type.</p>



<a name="189006052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189006052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189006052">(Feb 25 2020 at 10:11)</a>:</h4>
<p>Keep in mind that we can't make breaking changes to the standard library in an edition upgrade, since the same libstd is used by code from all editions.</p>



<a name="189006726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189006726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189006726">(Feb 25 2020 at 10:21)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> Yeah, well <code>alloc</code> solves the Box problem, but not the <code>errno</code> usage we have.  obviously things like <code>IoSlice</code> will need to stay in <code>std</code>.<br>
You're right about the editions. I guess if this is done it must not be a breaking change.<br>
we could maybe move the error type itself to <code>alloc</code> but keep the implementation of <code>last_os_error</code> in std? that will either require importing a trait(breaking change) or do some other magic</p>



<a name="189006841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189006841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189006841">(Feb 25 2020 at 10:23)</a>:</h4>
<p>btw, why is custom itself Boxed?(the error inside of custom is already boxed)</p>



<a name="189010150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189010150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189010150">(Feb 25 2020 at 11:11)</a>:</h4>
<p>I wonder if there are enough changes we would like to make to <code>std::io</code> but can’t that together they are worth making a new <code>io2</code> module with other traits etc</p>



<a name="189010292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189010292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Sapin <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189010292">(Feb 25 2020 at 11:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="249222">Elichai Turkel</span> <a href="#narrow/stream/219381-t-libs/topic/core.3A.3Aio/near/189006841" title="#narrow/stream/219381-t-libs/topic/core.3A.3Aio/near/189006841">said</a>:</p>
<blockquote>
<p>btw, why is custom itself Boxed?(the error inside of custom is already boxed)</p>
</blockquote>
<p>I would guess to keep the enum small and don’t force users of other variants to copy more padding bytes</p>



<a name="189010841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189010841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189010841">(Feb 25 2020 at 11:21)</a>:</h4>
<blockquote>
<p>I would guess to keep the enum small and don’t force users of other variants to copy more padding bytes</p>
</blockquote>
<p>hmm Well if we really believe most people don't use Custom then I guess it's fine, I just cringe on the double indirection</p>



<a name="189010942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189010942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189010942">(Feb 25 2020 at 11:22)</a>:</h4>
<p><code>io2</code> might be a good idea. but I have a feeling it will decrease the possibility of it happening because that means no constraints from the current system and back to the drawing board to design a new better io module</p>
<p>Maybe start a list of everything we want to change in <code>io</code> and see if it's worth deprecating the old io?</p>



<a name="189191563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189191563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189191563">(Feb 27 2020 at 07:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="249222">Elichai Turkel</span> <a href="#narrow/stream/219381-t-libs/topic/core.3A.3Aio/near/189010841" title="#narrow/stream/219381-t-libs/topic/core.3A.3Aio/near/189010841">said</a>:</p>
<blockquote>
<blockquote>
<p>I would guess to keep the enum small and don’t force users of other variants to copy more padding bytes</p>
</blockquote>
<p>hmm Well if we really believe most people don't use Custom then I guess it's fine, I just cringe on the double indirection</p>
</blockquote>
<p>This is trading inefficiency in the error case (more indirection to access error data) for more efficiency in the success case (smaller io::Result::Err means less data on the stack to copy around for calls and such). Seems like the right trade to me even if people <em>do</em> use Custom</p>



<a name="189306461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/189306461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#189306461">(Feb 28 2020 at 12:51)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> if that's the reason then we can instead put the whole Repr enum in a box. That way the error case will be 8 bytes instead of the current 16</p>



<a name="190836212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/190836212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#190836212">(Mar 17 2020 at 11:44)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> <br>
how bad is it to call errno from liballoc?<br>
if we-will provide a shim that either panics/returns some default when there's no OS. <br>
this is the only real problem with moving std::io to alloc::io</p>



<a name="190836268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/core%3A%3Aio/near/190836268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/core.3A.3Aio.html#190836268">(Mar 17 2020 at 11:45)</a>:</h4>
<p>That's probably a deal-breaker.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>